package Base.CommonClass.ObjectTest;

/*
 * @author 枫城
 * @createTime 2022/9/5 17:42
 * @desc equals 和 == 的区别
 */


import java.util.Date;

public class EqualsTest {
    public static void main(String[] args) {
        int j = 10;
        int i =10;
        double d = 10.0;
        System.out.println(i == j);  // true
        System.out.println(i == d);  // true

        char c = 10;
        System.out.println(i == c);  // true

        // 注意，此时为单引号
        char c1 ='A';
        char c2 = 65;
        System.out.println(c1 == c2);  // true

        final Customer tom = new Customer("Tom", 22);
        final Customer tom1 = new Customer("Tom", 22);

        System.out.println(tom == tom1); // false

        String str1 = new String("FengCheng");
        String str2 = new String("FengCheng");

        System.out.println(tom.equals(tom1)); // false
        System.out.println(str1.equals(str2)); // true

        Date d1 = new Date(12344846L);
        Date d2 = new Date(12344846L);
        System.out.println(d1.equals(d2));

    }
}
